package com.ruoyi.web.controller.task;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.task.domain.TaskWithdraw;
import com.ruoyi.task.service.ITaskWithdrawService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-17
 */
@RestController
@RequestMapping("/system/withdraw")
public class TaskWithdrawController extends BaseController
{
    @Autowired
    private ITaskWithdrawService taskWithdrawService;

    /**
     * 查询提现管理列表
     */
  //  @PreAuthorize("@ss.hasPermi('system:withdraw:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskWithdraw taskWithdraw)
    {
        startPage();
        List<TaskWithdraw> list = taskWithdrawService.selectTaskWithdrawList(taskWithdraw);
        return getDataTable(list);
    }

    @PostMapping("process")
    public AjaxResult process(@RequestBody TaskWithdraw taskWithdraw)
    {
        taskWithdraw.setExamineTime(new Date());
        return toAjax(taskWithdrawService.updateTaskWithdraw(taskWithdraw));
    }

    /**
     * 导出提现管理列表
     */
 //   @PreAuthorize("@ss.hasPermi('system:withdraw:export')")
    @Log(title = "提现管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskWithdraw taskWithdraw)
    {
        List<TaskWithdraw> list = taskWithdrawService.selectTaskWithdrawList(taskWithdraw);
        ExcelUtil<TaskWithdraw> util = new ExcelUtil<TaskWithdraw>(TaskWithdraw.class);
        util.exportExcel(response, list, "提现管理数据");
    }

    /**
     * 获取提现管理详细信息
     */
 //   @PreAuthorize("@ss.hasPermi('system:withdraw:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(taskWithdrawService.selectTaskWithdrawById(id));
    }

    /**
     * 新增提现管理
     */
 //   @PreAuthorize("@ss.hasPermi('system:withdraw:add')")
    @Log(title = "提现管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskWithdraw taskWithdraw)
    {
        return toAjax(taskWithdrawService.insertTaskWithdraw(taskWithdraw));
    }

    /**
     * 修改提现管理
     */
  //  @PreAuthorize("@ss.hasPermi('system:withdraw:edit')")
    @Log(title = "提现管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskWithdraw taskWithdraw)
    {
        return toAjax(taskWithdrawService.updateTaskWithdraw(taskWithdraw));
    }

    /**
     * 删除提现管理
     */
 //   @PreAuthorize("@ss.hasPermi('system:withdraw:remove')")
    @Log(title = "提现管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskWithdrawService.deleteTaskWithdrawByIds(ids));
    }
}
